package com.ys;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @program: note
 * @description:
 * @author:
 * @create 2020-06-11 22:39
 **/
public class Main {
    private static ConsumeRecordController consumeRecordController = new ConsumeRecordController();

    public static void main(String[] args) {
        boolean isFirst = true;
        while (true) {
            if (!isFirst) {
                System.out.println("请点击任意键继续...");
                try {
                    System.in.read();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            System.out.println("==================欢迎进入小账本!==================");
            System.out.println("输入0 退出小账本");
            System.out.println("输入 1 2020-06-11 牙膏 15 2 生活用品 // 记录消费信息, 包括[时间, 物品名称, 单价, 数量, 类别]");
            System.out.println("输入 2 2020-06-11 2020-06-11 // 统计指定时间段内的消费总花费");
            System.out.println("输入 3 2020-06-11 2020-06-11 // 统计指定时间段内的每件物品的消费数额");
            System.out.println("输入 4 2020-06-11 2020-06-11 // 统计指定时间段内的购买数量最多的商品的数量和金额");
            System.out.println("输入 5 2020-06-11 2020-06-11 // 统计指定时间段内的各类别商品的数量和金额");
            System.out.println("请您输入:\n");

            InputStreamReader is = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(is);
            try {
                String line = br.readLine();
                String[] array = line.split(" ");
                switch (array[0]) {
                    case "0": {
                        System.out.println("感谢您的使用, 正在退出");
                        return;
                    }
                    case "1": {
                        new CommandSave(consumeRecordController, array).execute();
                    } break;
                    case "2": {
                        new CommandTotalCost(consumeRecordController, array).execute();
                    } break;
                    case "3": {
                        new CommandNameCost(consumeRecordController, array).execute();
                    } break;
                    case "4": {
                        new CommandMostCost(consumeRecordController, array).execute();
                    } break;
                    case "5": {
                        new CommandTypeCost(consumeRecordController, array).execute();
                    } break;
                    default: break;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

            isFirst = false;
        }
    }
}
